var Koa =require('koa');
var router =require('koa-router')(); 
var views=require('koa-views')
var bodyParser=require('koa-bodyparser') //使用bodyparser1.安装引入
var static =require('koa-static')
var render=require('koa-art-template')
var path=require('path')
var DB=require('./module/db')
var adminRouter=require('./routes/admin')
var apiRouter=require('./routes/api')
var app= new Koa();  

app.use(bodyParser())
render(app,{
    root:path.join(__dirname,'views'),//视图位置
    extname:'.html', //后缀名
    debug:process.env.NODE_ENV!=='production'
})

// 配置子路由

router.use('/admin',adminRouter.routes())//引入后启动路由
router.use('/api',apiRouter)//在模块中启动路由


app.use(router.routes())
app.use(router.allowedMethods()) 

app.listen(8081)